//
//  HAODE
//
//  Created by panquanReabam.com on 15/9/23.
//  Copyright (c) 2015年 reabam.com. All rights reserved.
//

#import "CheckVouchDetailViewController.h"
#import "UIViewExt.h"
#import "HttpRequest.h"
#import "UIImageView+WebCache.h"
#import "RDVTabBarController.h"
#import "MJRefresh.h"
#import "GoodsView.h"
#import "CashierNewViewController.h"
@interface CheckVouchDetailViewController ()<MBProgressHUDDelegate,UIGestureRecognizerDelegate,UINavigationControllerDelegate,UITextFieldDelegate,UITextViewDelegate,UISearchBarDelegate,UIScrollViewDelegate>
@property (strong, nonatomic) UIScrollView * scrollView;
@property (strong, nonatomic) NSString*whsId;
@end
@implementation CheckVouchDetailViewController
{
   
    UIButton* operationsBtn;
    UIButton*cardBtn;
    float lastContentOffset;
    UIButton*daogouname;
    UIButton*leixingBtn;
    UIButton*leixingBtn1;
    UIView*shoushiview;
    UIView*view;
    UIView*view1;
    GoodsView*shangpingView;
    UIScrollView*mainScroll;
    UIScrollView*MYmainScroll;
    UIScrollView*MYmainScroll1;
    UIScrollView*MYmainScroll2;
    NSMutableArray* arrrss2;
    NSMutableArray* arrrss3;
    UIButton *tureBtn;
    UIButton*gengduoBtn;
    UIButton *jiahaogengduo;
    NSMutableArray* arrrss;
    NSMutableArray* arrrss1;
    UILabel* weightke;
    UIView*view2;
    UIView*view3;
    UIView*view4;
    UIButton* bu;
    UIButton* bu1;
    UIButton* bu2;
    UILabel* shelfNo;
    UIButton*i12;
    UILabel*isActive;
    bool saveAccount;
    NSString* Token;
     UILabel*NoLabel2;
    UILabel*NoLabel;
    UILabel*NoLabel1;
}
@synthesize alt = alt;

-(void)BackAction:(UIButton *)sender{
    
    NSUserDefaults*pushJudge = [NSUserDefaults standardUserDefaults];
    if([[pushJudge objectForKey:@"push"]isEqualToString:@"push"]) {
        NSUserDefaults * pushJudge = [NSUserDefaults standardUserDefaults];
        [pushJudge setObject:@""forKey:@"push"];
        [pushJudge synchronize];//记得立即同步
        [self dismissViewControllerAnimated:YES completion:nil];
        
    }else{
        [self.navigationController popViewControllerAnimated:YES];
    }
    
    
}
- (void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
    self.navigationController.delegate = nil;
    
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [[self rdv_tabBarController] setTabBarHidden:YES];
    self.navigationController.navigationBarHidden=NO;
        self.navigationController.navigationBar.barStyle = UIBaselineAdjustmentNone;
    UILabel *lineLabel=[[UILabel alloc] initWithFrame:CGRectMake(0, 43,ScreenWidth, 1)];
    [lineLabel setBackgroundColor:[UIColor colorWithRed:238.0/255.0 green:238.0/255.0 blue:238.0/255.0 alpha:1.0]];
    [self.navigationController.navigationBar addSubview:lineLabel];
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
    [[UINavigationBar appearance] setBarTintColor:Color];
    
    UIImage* backImage = [UIImage imageNamed:@"fanhui"];
    CGRect backframe = CGRectMake(0,0,30,30);
    UIButton* backButton= [[UIButton alloc] initWithFrame:backframe];
    [backButton setBackgroundImage:backImage forState:UIControlStateNormal];
    backButton.titleLabel.textAlignment=NSTextAlignmentLeft;
    [backButton addTarget:self action:@selector(BackAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem* leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    self.navigationItem.leftBarButtonItem = leftBarButtonItem;
    self.navigationController.delegate = self;
    
    self.navigationController.interactivePopGestureRecognizer.delegate = self;
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@""] forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage =[[UIImage alloc] init];
    self.title = @"盘点详情";
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                                     backColor,
                                                                     UITextAttributeTextColor,
                                                                     [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1],
                                                                     UITextAttributeTextShadowColor,
                                                                     [NSValue valueWithUIOffset:UIOffsetMake(0, 0)],
                                                                     UITextAttributeTextShadowOffset,
                                                                     [UIFont fontWithName:@"Helvetica Neue" size:tetlefot],
                                                                     UITextAttributeFont,nil]];
 
}
-(void)xuanze:(UIButton*)sender{
    saveAccount=!saveAccount;
    if (saveAccount) {
        shoushiview=[[UIView alloc]initWithFrame:CGRectMake(0, 64, ScreenWidth, ScreenHeight)];
        shoushiview.backgroundColor=[UIColor clearColor];
        [self.view addSubview:shoushiview];
        UITapGestureRecognizer *singleFingerOne = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeKeyBoad)];
        singleFingerOne.numberOfTouchesRequired = 1; //手指数
        singleFingerOne.numberOfTapsRequired = 1; //tap次数
        singleFingerOne.delegate = self;
        [shoushiview addGestureRecognizer:singleFingerOne];
        i12=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth-168/2, 0,168/2, 110)];
        i12.backgroundColor=[UIColor colorWithRed:90/255.0 green:130/255.0 blue:26/255.0 alpha:1.0];
        [i12 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        i12.titleLabel.font=[UIFont systemFontOfSize:contenfot];
        [i12 addTarget:self action:@selector(anzhuangqueren:) forControlEvents:UIControlEventTouchUpInside];
        if ([[self.Dict objectForKey:@"ckvStatus"] isEqualToString:@"NP"]) {
            [i12 addTarget:self action:@selector(anzhuangqueren:) forControlEvents:UIControlEventTouchUpInside];
            [i12 setTitle:@"开始盘点" forState:UIControlStateNormal];
        }else if ([[self.Dict objectForKey:@"ckvStatus"] isEqualToString:@"YP"]){
            [i12 addTarget:self action:@selector(anzhuangqueren:) forControlEvents:UIControlEventTouchUpInside];
            [i12 setTitle:@"盘点录入" forState:UIControlStateNormal];
        }
        [shoushiview addSubview:i12];

        }else{
               [i12 removeFromSuperview];
               [shoushiview removeFromSuperview];
        
    }
}
//开始盘点
-(void)anzhuangqueren:(UIButton*)sender{
    if ([[self.Dict objectForKey:@"ckvStatus"] isEqualToString:@"NP"]) {
        NSMutableDictionary *param = [NSMutableDictionary new];
        [param setValue:Token forKey:@"tokenId"];
        [param setValue:self.orderId forKey:@"ckvId"];
        [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
        [HttpRequest requestData:@"Business/CheckVouch/Add" params:param success:^(BOOL isSuccess, SeverData *severDataDict) {
            if (isSuccess) {
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                    [Global hideProgressHUDInternal:self.view];
                    [self jiazaishuju];
                    [_delegate upster:@""];
                    [i12 removeFromSuperview];
                    [shoushiview removeFromSuperview];
                
                }else{
                    [Global hideProgressHUDInternal:self.view];
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    [Global showTextHudSub:requestResultStr view:self.view];
                }
            }
            else
            {
                [Global hideProgressHUDInternal:self.view];
                [Global showTextHudSub:severDataDict.resultStr view:self.view];
            }
            
        }];

    
    }else{
        [i12 removeFromSuperview];
        [shoushiview removeFromSuperview];

        CashierNewViewController *detailViewController = [[CashierNewViewController alloc] init];
        [Global setScanTitle:@"扫盘点"];
//        [Global setType:@"CheckVouch"];
        [Global setType:@"Continue"];
        [Global setPlaceOrderPType:@"saleItem"];
        detailViewController.ckvId=self.orderId;
        detailViewController.ckvNo=shelfNo.text;
        detailViewController.whsName=[self.Dict objectForKey:@"whsName"];
        detailViewController.itemTypeName=[self.Dict objectForKey:@"itemTypeName"];
        detailViewController.whsId=[self.Dict objectForKey:@"whsId"];
        detailViewController.itemTypeCode=[self.Dict objectForKey:@"itemTypeCode"];
        [self.navigationController pushViewController:detailViewController animated:YES];


    }
}
- (void)viewDidLoad
{
    
    [super viewDidLoad];
    NSUserDefaults *user2 = [NSUserDefaults standardUserDefaults];
    Token = [user2 objectForKey:@"tokenId"];
    [self jiazaishuju];
    
}
-(void)jiazaishuju{
    [view2 removeFromSuperview];
    [MYmainScroll removeFromSuperview];
    [MYmainScroll1 removeFromSuperview];
    [MYmainScroll2 removeFromSuperview];
    [self.scrollView removeFromSuperview];
    [self.customTabBar removeFromSuperview];
    self.view.backgroundColor=zuiqianhuiColor;
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setValue:Token forKey:@"tokenId"];
    [param setValue:self.orderId forKey:@"ckvId"];
    [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
    [HttpRequest requestData:@"Business/CheckVouch/Detail" params:param success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
//          NSLog(@"-----------%@", severDataDict.dataDict);
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [Global hideProgressHUDInternal:self.view];
                self.Dict=severDataDict.dataDict;
                view1=[[UIView alloc]initWithFrame:CGRectMake(0, 64, ScreenWidth, 70)];
                view1.backgroundColor=[UIColor whiteColor];
                [self.view addSubview:view1];
                NSString *s2 =[severDataDict.dataDict objectForKey:@"ckvNo"];
                UIFont *font2 = [UIFont systemFontOfSize:17];
                CGSize size2 = CGSizeMake(ScreenWidth-60, 2000);
                CGSize labelsize2 = [s2 sizeWithFont:font2 constrainedToSize:size2 lineBreakMode:NSLineBreakByCharWrapping];
                shelfNo=[[UILabel alloc]initWithFrame:CGRectMake(15, 15, labelsize2.width+5, 17)];
                shelfNo.text=[severDataDict.dataDict objectForKey:@"ckvNo"];
                shelfNo.textColor=qianheiColor;
                shelfNo.font=[UIFont systemFontOfSize:17];
                [view1 addSubview:shelfNo];
                
               isActive=[[UILabel alloc]initWithFrame:CGRectMake(shelfNo.right, 15, 45, 17)];
                if ([[NSString stringWithFormat:@"%@",  [severDataDict.dataDict objectForKey:@"ckvStatus"]]isEqualToString:@"YT"]) {
                    [isActive setTextColor:luseColor];
                    isActive.text=[NSString stringWithFormat:@"%@",  [severDataDict.dataDict objectForKey:@"ckvStatusName"]];
                    
                }else if ([[NSString stringWithFormat:@"%@",  [severDataDict.dataDict objectForKey:@"ckvStatus"]]isEqualToString:@"NP"]) {
                    
                    [isActive setTextColor:shenhongseColor];
                    
                    isActive.text=[NSString stringWithFormat:@"%@",  [severDataDict.dataDict objectForKey:@"ckvStatusName"]];
                }else if ([[NSString stringWithFormat:@"%@",  [severDataDict.dataDict objectForKey:@"ckvStatus"]]isEqualToString:@"YP"]) {
                        
                        [isActive setTextColor:shenhongseColor];
                        
                        isActive.text=[NSString stringWithFormat:@"%@",  [severDataDict.dataDict objectForKey:@"ckvStatusName"]];
                }else if ([[NSString stringWithFormat:@"%@",  [severDataDict.dataDict objectForKey:@"ckvStatus"]]isEqualToString:@"YF"]) {
                    
                    [isActive setTextColor:luseColor];
                    
                    isActive.text=[NSString stringWithFormat:@"%@",  [severDataDict.dataDict objectForKey:@"ckvStatusName"]];
                }else if ([[NSString stringWithFormat:@"%@",  [severDataDict.dataDict objectForKey:@"ckvStatus"]]isEqualToString:@"YC"]) {
                    
                    [isActive setTextColor:shenhuiColor];
                    isActive.text=[NSString stringWithFormat:@"%@",  [severDataDict.dataDict objectForKey:@"ckvStatusName"]];                    }

                isActive.font= [UIFont systemFontOfSize:13];
                isActive.textAlignment=NSTextAlignmentCenter;
                if ([[severDataDict.dataDict objectForKey:@"ckvStatus"] isEqualToString:@"NP"]||[[severDataDict.dataDict objectForKey:@"ckvStatus"] isEqualToString:@"YP"]) {
                    [operationsBtn removeFromSuperview];
                    operationsBtn = [[UIButton alloc] initWithFrame:CGRectMake(30, 0.0,  60/2, 60/2)];
                    [operationsBtn setTitle:@"···" forState:UIControlStateNormal];
                    operationsBtn.titleLabel.font=[UIFont systemFontOfSize:28];
                    [operationsBtn setTitleColor:shenhuiColor forState:UIControlStateNormal];
                    [operationsBtn addTarget:self action:@selector(xuanze:) forControlEvents:UIControlEventTouchUpInside];
                    UIBarButtonItem* myBtnBtn = [[UIBarButtonItem alloc] initWithCustomView:operationsBtn];
                    self.navigationItem.rightBarButtonItem = myBtnBtn;

                }
                [view1 addSubview:isActive];
                
                UILabel *line1=[[UILabel alloc] initWithFrame:CGRectMake(0, 70, ScreenWidth, 0.40)];
                line1.backgroundColor=qianhuiColor;
                [view1 addSubview:line1];
                UILabel* duogou=[[UILabel alloc]initWithFrame:CGRectMake(15, 85/2, 33, contenfot)];
                duogou.text=[NSString stringWithFormat:@"员工"];
                duogou.textColor=zhonghuiColor;
                duogou.font=[UIFont systemFontOfSize:contenfot];
                [view1 addSubview:duogou];
                NSString *createName1 = [severDataDict.dataDict objectForKey:@"userName"];
                UIFont *createNamefont1 = [UIFont systemFontOfSize:contenfot];
                CGSize createNamesize1 = CGSizeMake(ScreenWidth-60, 2000);
                CGSize createNamelabelsize1 = [createName1 sizeWithFont:createNamefont1 constrainedToSize:createNamesize1 lineBreakMode:NSLineBreakByCharWrapping];
                
                daogouname=[[UIButton alloc]initWithFrame:CGRectMake(duogou.right, 85/2,createNamelabelsize1.width+15,contenfot)];
                [daogouname setTitle:createName1 forState:UIControlStateNormal];
                daogouname.titleLabel.font=[UIFont systemFontOfSize:contenfot];
                daogouname.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft;
                [daogouname setTitleColor:shenhuiColor forState:UIControlStateNormal];
                [view1 addSubview:daogouname];

                UILabel* orderDate=[[UILabel alloc]initWithFrame:CGRectMake(daogouname.right, 85/2, 33, contenfot)];
                orderDate.text=@"日期";
                orderDate.textColor=zhonghuiColor;
                orderDate.font=[UIFont systemFontOfSize:contenfot];
                [view1 addSubview:orderDate];
             
                NSString* string =[severDataDict.dataDict  objectForKey:@"createDate"];
                UILabel* orderDate1=[[UILabel alloc]initWithFrame:CGRectMake(orderDate.right, 85/2, 180, contenfot)];
                orderDate1.text=string;
                orderDate1.textColor=shenhuiColor;
                orderDate1.font=[UIFont systemFontOfSize:contenfot];
                [view1 addSubview:orderDate1];
          
         
                view2=[[UIView alloc]initWithFrame:CGRectMake(0, view1.bottom+10, ScreenWidth, 31)];
                view2.backgroundColor=[UIColor whiteColor];
                view2.layer.borderWidth = 0.45;
                view2.layer.borderColor = qianhuiColor.CGColor;
                [self.view addSubview:view2];
                gengduoBtn=[[UIButton alloc]initWithFrame:CGRectMake(30,  0, ScreenWidth-50,31)];
                [gengduoBtn setTitle:@"更多" forState:UIControlStateNormal];
                gengduoBtn.titleLabel.font=[UIFont systemFontOfSize:12];
                [gengduoBtn addTarget:self action:@selector(gengduo:) forControlEvents:UIControlEventTouchUpInside];
                gengduoBtn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentRight;
                [gengduoBtn setTitleColor:luseColor forState:UIControlStateNormal];
                [view2 addSubview:gengduoBtn];
                jiahaogengduo=[UIButton buttonWithType:UIButtonTypeCustom];
                [jiahaogengduo setImage:[UIImage imageNamed:@"jiahaogengduo"] forState:UIControlStateNormal];
                [jiahaogengduo setFrame:CGRectMake(ScreenWidth-105, 0, 31,31)];
                 jiahaogengduo.userInteractionEnabled=NO;
                [gengduoBtn addSubview:jiahaogengduo];
                [self addd];
            }else{
                [Global hideProgressHUDInternal:self.view];
                NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                [Global showTextHudSub:requestResultStr view:self.view];
            }
            
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
           [Global showTextHudSub:severDataDict.resultStr view:self.view];
        }
        
    }];
}
-(void)gengduo:(UIButton*)sender{
        [gengduoBtn removeFromSuperview];
        [view2 removeFromSuperview];
    if ([sender.titleLabel.text isEqualToString:@"更多"]) {
        
        view2=[[UIView alloc]initWithFrame:CGRectMake(0, view1.bottom+10, ScreenWidth, 90)];
        view2.backgroundColor=[UIColor whiteColor];
        view2.layer.borderWidth = 0.45;
        view2.layer.borderColor = qianhuiColor.CGColor;
        [self.view addSubview:view2];
        UILabel *line3=[[UILabel alloc] initWithFrame:CGRectMake(10,  45-0.40, ScreenWidth-20, 0.40)];
        line3.backgroundColor=qianhuiColor;
        [view2 addSubview:line3];
        UILabel*leixing=[[UILabel alloc]initWithFrame:CGRectMake(15,0, 200, 45)];
        leixing.text=@"类型";
        leixing.textColor=shenhuiColor;
        leixing.font=[UIFont systemFontOfSize:contenfot];
        [view2 addSubview:leixing];
        leixingBtn=[[UIButton alloc]initWithFrame:CGRectMake(30,  0, ScreenWidth-50,45)];
        leixingBtn.titleLabel.font=[UIFont systemFontOfSize:contenfot];
        [leixingBtn setTitle:[self.Dict objectForKey:@"itemTypeName"] forState:UIControlStateNormal];
        
        leixingBtn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentRight;
        
        [leixingBtn setTitleColor:qianheiColor forState:UIControlStateNormal];
        [view2 addSubview:leixingBtn];
        
        UILabel*leixing1=[[UILabel alloc]initWithFrame:CGRectMake(15,45, 200, 45)];
        leixing1.text=@"仓库";
        leixing1.textColor=shenhuiColor;
        leixing1.font=[UIFont systemFontOfSize:contenfot];
        [view2 addSubview:leixing1];
        
        leixingBtn1=[[UIButton alloc]initWithFrame:CGRectMake(30,  45, ScreenWidth-50,45)];
        [leixingBtn1 setTitle:[self.Dict objectForKey:@"whsName"] forState:UIControlStateNormal];
        leixingBtn1.titleLabel.font=[UIFont systemFontOfSize:contenfot];
        leixingBtn1.contentHorizontalAlignment=UIControlContentHorizontalAlignmentRight;
        [leixingBtn1 setTitleColor:qianheiColor forState:UIControlStateNormal];
        [view2 addSubview:leixingBtn1];
        
        
        gengduoBtn=[[UIButton alloc]initWithFrame:CGRectMake(30,  0, ScreenWidth-50,31)];
        [gengduoBtn setTitle:@"收起" forState:UIControlStateNormal];
        gengduoBtn.titleLabel.font=[UIFont systemFontOfSize:12];
        [gengduoBtn addTarget:self action:@selector(gengduo:) forControlEvents:UIControlEventTouchUpInside];
        gengduoBtn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentRight;
        [gengduoBtn setTitleColor:luseColor forState:UIControlStateNormal];
        [view2 addSubview:gengduoBtn];
        jiahaogengduo=[UIButton buttonWithType:UIButtonTypeCustom];
        [jiahaogengduo setImage:[UIImage imageNamed:@"jianhaoshouqi"] forState:UIControlStateNormal];
        [jiahaogengduo setFrame:CGRectMake(ScreenWidth-105, 0, 31,31)];
        jiahaogengduo.userInteractionEnabled=NO;
        [gengduoBtn addSubview:jiahaogengduo];

        
        if ([[NSString stringWithFormat:@"%@",  [self.Dict objectForKey:@"ckvStatus"]]isEqualToString:@"NP"]){
            
            NSString* remarkStr=[NSString stringWithFormat:@"%@",  [self.Dict objectForKey:@"remark"]];
            UIFont *font1 = [UIFont systemFontOfSize:contenfot];
            CGSize size1 = CGSizeMake(ScreenWidth-60, 2000);
            CGSize labelsize1 = [remarkStr sizeWithFont:font1 constrainedToSize:size1 lineBreakMode:NSLineBreakByCharWrapping];
            UILabel *line13=[[UILabel alloc] initWithFrame:CGRectMake(10,  90-0.40, ScreenWidth-20, 0.40)];
            line13.backgroundColor=qianhuiColor;
            [view2 addSubview:line13];
            UIView*remarkView=[[UIView alloc]initWithFrame:CGRectMake(0,90+0.45, ScreenWidth, 75)];
            remarkView.backgroundColor=[UIColor whiteColor];
            [view2 addSubview:remarkView];
            
            UILabel*remarkLabel=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, ScreenWidth, 35)];
            remarkLabel.text=@"备注";
            remarkLabel.font= [UIFont systemFontOfSize:contenfot];
            [remarkLabel setTextColor:shenhuiColor];
            [remarkView addSubview:remarkLabel];
            
            UILabel*remarkLabel1=[[UILabel alloc]initWithFrame:CGRectMake(15, remarkLabel.bottom, ScreenWidth-30, labelsize1.height+10)];
            if (remarkStr.length>0) {
            }else{
                remarkStr=@"无";
            }
            remarkLabel1.text=remarkStr;
            remarkLabel1.numberOfLines=0;
            remarkLabel1.font= [UIFont systemFontOfSize:contenfot];
            [remarkLabel1 setTextColor:qianheiColor];
            [remarkView addSubview:remarkLabel1];
            remarkView.frame=CGRectMake(0, 90+0.45, ScreenWidth, remarkLabel1.height+45);
            
            view2.frame=CGRectMake(0, view1.bottom+10, ScreenWidth, remarkView.bottom+31);
            gengduoBtn.frame=CGRectMake(30, remarkView.bottom, ScreenWidth-50,31);
            
            UIImageView *_hengxian = [[UIImageView alloc]initWithFrame:CGRectMake(10,remarkView.bottom-0.4, ScreenWidth-20, 0.5)];
            _hengxian.image=[UIImage imageNamed:@"hengxian"];
            [view2 addSubview:_hengxian];
        }else  if ([[NSString stringWithFormat:@"%@",  [self.Dict objectForKey:@"ckvStatus"]]isEqualToString:@"YP"]||[[NSString stringWithFormat:@"%@",  [self.Dict objectForKey:@"ckvStatus"]]isEqualToString:@"YC"]){
            UILabel *line13=[[UILabel alloc] initWithFrame:CGRectMake(10,  90-0.40, ScreenWidth-20, 0.40)];
            line13.backgroundColor=qianhuiColor;
            [view2 addSubview:line13];
            UILabel *line23=[[UILabel alloc] initWithFrame:CGRectMake(10,  90+45, ScreenWidth-20, 0.40)];
            line23.backgroundColor=qianhuiColor;
            [view2 addSubview:line23];
            UILabel*leixing1=[[UILabel alloc]initWithFrame:CGRectMake(15,90, 200, 45)];
            leixing1.text=@"盘点开始时间";
            leixing1.textColor=shenhuiColor;
            leixing1.font=[UIFont systemFontOfSize:contenfot];
            [view2 addSubview:leixing1];
            
            UIButton*leixingBtn2=[[UIButton alloc]initWithFrame:CGRectMake(30,  90, ScreenWidth-50,45)];
            [leixingBtn2 setTitle:[self.Dict objectForKey:@"createDate"] forState:UIControlStateNormal];
            leixingBtn2.titleLabel.font=[UIFont systemFontOfSize:contenfot];
            leixingBtn2.contentHorizontalAlignment=UIControlContentHorizontalAlignmentRight;
            [leixingBtn2 setTitleColor:qianheiColor forState:UIControlStateNormal];
            [view2 addSubview:leixingBtn2];
            NSString* remarkStr=[NSString stringWithFormat:@"%@",  [self.Dict objectForKey:@"remark"]];
            UIFont *font1 = [UIFont systemFontOfSize:contenfot];
            CGSize size1 = CGSizeMake(ScreenWidth-60, 2000);
            CGSize labelsize1 = [remarkStr sizeWithFont:font1 constrainedToSize:size1 lineBreakMode:NSLineBreakByCharWrapping];
            
            UIView*remarkView=[[UIView alloc]initWithFrame:CGRectMake(0,90+45+0.45, ScreenWidth, 75)];
            remarkView.backgroundColor=[UIColor whiteColor];
            [view2 addSubview:remarkView];
            
            UILabel*remarkLabel=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, ScreenWidth, 35)];
            remarkLabel.text=@"备注";
            remarkLabel.font= [UIFont systemFontOfSize:contenfot];
            [remarkLabel setTextColor:shenhuiColor];
            [remarkView addSubview:remarkLabel];
            
            UILabel*remarkLabel1=[[UILabel alloc]initWithFrame:CGRectMake(15, remarkLabel.bottom, ScreenWidth-30, labelsize1.height+10)];
            if (remarkStr.length>0) {
            }else{
                remarkStr=@"无";
            }
            remarkLabel1.text=remarkStr;
            remarkLabel1.numberOfLines=0;
            remarkLabel1.font= [UIFont systemFontOfSize:contenfot];
            [remarkLabel1 setTextColor:qianheiColor];
            [remarkView addSubview:remarkLabel1];
            remarkView.frame=CGRectMake(0, 90+45+0.45, ScreenWidth, remarkLabel1.height+45);
            gengduoBtn.frame=CGRectMake(30, remarkView.bottom, ScreenWidth-50,31);
            view2.frame=CGRectMake(0, view1.bottom+10, ScreenWidth, remarkView.bottom+31);
            UIImageView *_hengxian = [[UIImageView alloc]initWithFrame:CGRectMake(10,remarkView.bottom-0.4, ScreenWidth-20, 0.5)];
            _hengxian.image=[UIImage imageNamed:@"hengxian"];
            [view2 addSubview:_hengxian];
            
        }else  if ([[NSString stringWithFormat:@"%@",  [self.Dict objectForKey:@"ckvStatus"]]isEqualToString:@"YT"]||[[NSString stringWithFormat:@"%@",  [self.Dict objectForKey:@"ckvStatus"]]isEqualToString:@"YF"]){
            
            
            UILabel *line13=[[UILabel alloc] initWithFrame:CGRectMake(10,  90-0.40, ScreenWidth-20, 0.40)];
            line13.backgroundColor=qianhuiColor;
            [view2 addSubview:line13];
            UILabel *line23=[[UILabel alloc] initWithFrame:CGRectMake(10,  90+45, ScreenWidth-20, 0.40)];
            line23.backgroundColor=qianhuiColor;
            [view2 addSubview:line23];
            UILabel *line33=[[UILabel alloc] initWithFrame:CGRectMake(10,  90+45+45, ScreenWidth-20, 0.40)];
            line33.backgroundColor=qianhuiColor;
            [view2 addSubview:line33];
            
            UILabel*leixing1=[[UILabel alloc]initWithFrame:CGRectMake(15,90, 200, 45)];
            leixing1.text=@"盘点开始时间";
            leixing1.textColor=shenhuiColor;
            leixing1.font=[UIFont systemFontOfSize:contenfot];
            [view2 addSubview:leixing1];
            
            UIButton*leixingBtn2=[[UIButton alloc]initWithFrame:CGRectMake(30,  90, ScreenWidth-50,45)];
            [leixingBtn2 setTitle:[self.Dict objectForKey:@"createDate"] forState:UIControlStateNormal];
            leixingBtn2.titleLabel.font=[UIFont systemFontOfSize:contenfot];
            leixingBtn2.contentHorizontalAlignment=UIControlContentHorizontalAlignmentRight;
            [leixingBtn2 setTitleColor:qianheiColor forState:UIControlStateNormal];
            [view2 addSubview:leixingBtn2];
            
            UILabel*leixing2=[[UILabel alloc]initWithFrame:CGRectMake(15,90+45, 200, 45)];
            leixing2.text=@"盘点确认时间";
            leixing2.textColor=shenhuiColor;
            leixing2.font=[UIFont systemFontOfSize:contenfot];
            [view2 addSubview:leixing2];
            
            UIButton*leixingBtn22=[[UIButton alloc]initWithFrame:CGRectMake(30,  90+45, ScreenWidth-50,45)];
            [leixingBtn22 setTitle:[self.Dict objectForKey:@"endDate"] forState:UIControlStateNormal];
            leixingBtn22.titleLabel.font=[UIFont systemFontOfSize:contenfot];
            leixingBtn22.contentHorizontalAlignment=UIControlContentHorizontalAlignmentRight;
            [leixingBtn22 setTitleColor:qianheiColor forState:UIControlStateNormal];
            [view2 addSubview:leixingBtn22];
            
            NSString* remarkStr=[NSString stringWithFormat:@"%@",  [self.Dict objectForKey:@"remark"]];
            UIFont *font1 = [UIFont systemFontOfSize:contenfot];
            CGSize size1 = CGSizeMake(ScreenWidth-60, 2000);
            CGSize labelsize1 = [remarkStr sizeWithFont:font1 constrainedToSize:size1 lineBreakMode:NSLineBreakByCharWrapping];
            
            UIView*remarkView=[[UIView alloc]initWithFrame:CGRectMake(0,90+90+0.45, ScreenWidth, 75)];
            remarkView.backgroundColor=[UIColor whiteColor];
            [view2 addSubview:remarkView];
            
            UILabel*remarkLabel=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, ScreenWidth, 35)];
            remarkLabel.text=@"备注";
            remarkLabel.font= [UIFont systemFontOfSize:contenfot];
            [remarkLabel setTextColor:shenhuiColor];
            [remarkView addSubview:remarkLabel];
            
            UILabel*remarkLabel1=[[UILabel alloc]initWithFrame:CGRectMake(15, remarkLabel.bottom, ScreenWidth-30, labelsize1.height+10)];
            if (remarkStr.length>0) {
            }else{
                remarkStr=@"无";
            }
            remarkLabel1.text=remarkStr;
            remarkLabel1.numberOfLines=0;
            remarkLabel1.font= [UIFont systemFontOfSize:contenfot];
            [remarkLabel1 setTextColor:qianheiColor];
            [remarkView addSubview:remarkLabel1];
            remarkView.frame=CGRectMake(0, 90+90+0.45, ScreenWidth, remarkLabel1.height+45);
            gengduoBtn.frame=CGRectMake(30, remarkView.bottom, ScreenWidth-50,31);
            view2.frame=CGRectMake(0, view1.bottom+10, ScreenWidth, remarkView.bottom+31);
            UIImageView *_hengxian = [[UIImageView alloc]initWithFrame:CGRectMake(10,remarkView.bottom-0.4, ScreenWidth-20, 0.5)];
            _hengxian.image=[UIImage imageNamed:@"hengxian"];
            [view2 addSubview:_hengxian];
        
        
        }

    
    self.scrollView.frame = CGRectMake(0, view2.bottom+50+10, ScreenWidth, ScreenHeight-220);
    self.customTabBar.frame=CGRectMake(0,view2.bottom+10, ScreenWidth, 50);
   
    }else{
        view2=[[UIView alloc]initWithFrame:CGRectMake(0, view1.bottom+10, ScreenWidth, 31)];
        view2.backgroundColor=[UIColor whiteColor];
        view2.layer.borderWidth = 0.45;
        view2.layer.borderColor = qianhuiColor.CGColor;
        [self.view addSubview:view2];
        gengduoBtn=[[UIButton alloc]initWithFrame:CGRectMake(30,  0, ScreenWidth-50,31)];
        [gengduoBtn setTitle:@"更多" forState:UIControlStateNormal];
        gengduoBtn.titleLabel.font=[UIFont systemFontOfSize:12];
        [gengduoBtn addTarget:self action:@selector(gengduo:) forControlEvents:UIControlEventTouchUpInside];
        gengduoBtn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentRight;
        [gengduoBtn setTitleColor:luseColor forState:UIControlStateNormal];
        [view2 addSubview:gengduoBtn];
        jiahaogengduo=[UIButton buttonWithType:UIButtonTypeCustom];
        [jiahaogengduo setImage:[UIImage imageNamed:@"jiahaogengduo"] forState:UIControlStateNormal];
        [jiahaogengduo setFrame:CGRectMake(ScreenWidth-105, 0, 31,31)];
        jiahaogengduo.userInteractionEnabled=NO;
        [gengduoBtn addSubview:jiahaogengduo];
        self.scrollView.frame = CGRectMake(0, view2.bottom+50+10, ScreenWidth, ScreenHeight-220);
        self.customTabBar.frame=CGRectMake(0,view2.bottom+10, ScreenWidth, 50);
    
    }
}
-(void)closeKeyBoad
{
    [i12 removeFromSuperview];
    [shoushiview removeFromSuperview];
}
    
-(void)jiazai{
    [NoLabel1 removeFromSuperview];
    [NoLabel removeFromSuperview];
    NSMutableDictionary *param1 = [NSMutableDictionary new];
    [param1 setValue:Token forKey:@"tokenId"];
    [param1 setValue:self.orderId forKey:@"ckvId"];
    [param1 setValue:@"balance" forKey:@"ckStatus"];
    [HttpRequest requestData:@"Business/CheckVouch/ItemList" params:param1 success:^(BOOL isSuccess, SeverData *severDataDict) {
    if (isSuccess) {
            NSLog(@"balance-----------%@", severDataDict.dataDict);
        if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [Global hideProgressHUDInternal:self.view];
                arrrss=[[NSMutableArray alloc]init];
                arrrss=[severDataDict.dataDict objectForKey:@"DataLine"];
    if (arrrss.count>0) {
        
        for (int i = 0; i<arrrss.count; i++) {
            
            shangpingView = [[GoodsView alloc]initWithFrame:CGRectMake(0, 45+(120*i), ScreenWidth, 120)];
            shangpingView.backgroundColor=[UIColor whiteColor];
            [shangpingView.headImageFull setImageWithURL:[[arrrss objectAtIndex:i] objectForKey:@"imageUrlFull"] placeholderImage:[UIImage imageNamed:@"zhengfangxing"]];
            [shangpingView.headImageFull.layer setCornerRadius:6.0];
            [shangpingView.headImageFull.layer setBorderWidth:0.5];
            [shangpingView.headImageFull.layer setMasksToBounds:YES];
            CGColorSpaceRef colorSpace2 = CGColorSpaceCreateDeviceRGB();
            CGColorRef colorref2 = CGColorCreate(colorSpace2,(CGFloat[]){ 0.93, 0.93, 0.93, 0.93 });
            [shangpingView.headImageFull.layer setBorderColor:colorref2];//边框颜色
            
            shangpingView.itemName.text=[NSString stringWithFormat:@"%@ %@",[[arrrss objectAtIndex:i] objectForKey:@"itemCode"],[[arrrss objectAtIndex:i] objectForKey:@"itemName"]];
            shangpingView.itemType.text=[NSString stringWithFormat:@"%@",[[arrrss objectAtIndex:i] objectForKey:@"specName"]];
            if ([[NSString stringWithFormat:@"%@",  [self.Dict objectForKey:@"ckvStatus"]]isEqualToString:@"NP"]) {
            
             }else{
            
            shangpingView.quantity.text=[NSString stringWithFormat:@"盘点日库存 %@",[[arrrss objectAtIndex:i] objectForKey:@"inWhsQuantity"]];
            
            NSMutableAttributedString *AttributedStr1 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"盘点日库存 %@",[[arrrss objectAtIndex:i] objectForKey:@"inWhsQuantity"]]];
            
            [AttributedStr1 addAttribute:NSFontAttributeName
             
                                   value:[UIFont systemFontOfSize:13]
             
                                   range:NSMakeRange(0, 5)];
            
            [AttributedStr1 addAttribute:NSForegroundColorAttributeName
             
                                   value:shenhuiColor
             
                                   range:NSMakeRange(0, 5)];
            
            
            shangpingView.quantity.attributedText = AttributedStr1;
            shangpingView.dealPrice.text=[NSString stringWithFormat:@"已盘点 %@",[[arrrss objectAtIndex:i] objectForKey:@"quantity"]];
            shangpingView.dealPrice.textColor=hongseColor;
              shangpingView.dealPrice.font=[UIFont systemFontOfSize:13];
            NSMutableAttributedString *AttributedStr12 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"已盘点 %@",[[arrrss objectAtIndex:i] objectForKey:@"quantity"]]];
            
            [AttributedStr12 addAttribute:NSFontAttributeName
             
                                    value:[UIFont systemFontOfSize:13]
             
                                    range:NSMakeRange(0, 3)];
            
            [AttributedStr12 addAttribute:NSForegroundColorAttributeName
             
                                    value:shenhuiColor
             
                                    range:NSMakeRange(0, 3)];
            
            
            shangpingView.dealPrice.attributedText = AttributedStr12;
           }if (i==arrrss.count-1) {
                UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(0, 120-0.40, ScreenWidth, 0.40)];
                lineLabel1.backgroundColor=qianhuiColor;
                [shangpingView addSubview:lineLabel1];
            }else{
                UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(10, 120-0.40, ScreenWidth-20, 0.40)];
                lineLabel1.backgroundColor=qianhuiColor;
                [shangpingView addSubview:lineLabel1];
            }
            
            [MYmainScroll addSubview:shangpingView];
            
        }
        
               MYmainScroll.contentSize = CGSizeMake(ScreenWidth, shangpingView.bottom+100);
    } else{
        
        NoLabel2=[[UILabel alloc]initWithFrame:CGRectMake(0, 120, ScreenWidth, 45)];
        NoLabel2.text=@"暂无盘存商品信息！";
        NoLabel2.textAlignment=NSTextAlignmentCenter;
        NoLabel2.textColor=shenhuiColor;
        NoLabel2.font=[UIFont systemFontOfSize:15];
        [MYmainScroll addSubview:NoLabel2];
        
        
    }
            UIView*shangpingxinxiview=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 45)];
            shangpingxinxiview.backgroundColor=[UIColor whiteColor];
            [MYmainScroll addSubview:shangpingxinxiview];
            UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(10, 45-0.40, ScreenWidth-20, 0.40)];
            lineLabel1.backgroundColor=qianhuiColor;
            [shangpingxinxiview addSubview:lineLabel1];
            
            UILabel*shangpingxinxi=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, 80, 45)];
            shangpingxinxi.text=@"商品信息";
            shangpingxinxi.textColor=qianheiColor;
            shangpingxinxi.font=[UIFont systemFontOfSize:15];
            [shangpingxinxiview addSubview:shangpingxinxi];
            UILabel*totalQuantity=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth-250, 0, 230, 45)];
            totalQuantity.textColor = shenhuiColor;
            totalQuantity.textAlignment = NSTextAlignmentRight;
            totalQuantity.text=[NSString stringWithFormat:@"共 %@ 件 已盘点 %@ 件",[severDataDict.dataDict objectForKey:@"InWhsTotal"],[severDataDict.dataDict objectForKey:@"QuantityTotal"]];
            totalQuantity.font = [UIFont systemFontOfSize:13];
            [shangpingxinxiview addSubview:totalQuantity];


            }else{
                [Global hideProgressHUDInternal:self.view];
                NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                [Global showTextHudSub:requestResultStr view:self.view];
            }
            
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
           
            [Global showTextHudSub:severDataDict.resultStr view:self.view];
        }
        
    }];
    NSMutableDictionary *param2 = [NSMutableDictionary new];
    [param2 setValue:Token forKey:@"tokenId"];
    [param2 setValue:self.orderId forKey:@"ckvId"];
    [param2 setValue:@"gain" forKey:@"ckStatus"];
    [HttpRequest requestData:@"Business/CheckVouch/ItemList" params:param2 success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
            NSLog(@"gain======----------------------%@", severDataDict.dataDict);
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [Global hideProgressHUDInternal:self.view];
                arrrss1=[[NSMutableArray alloc]init];
                arrrss1=[severDataDict.dataDict objectForKey:@"DataLine"];

                if (arrrss1.count>0) {
                    
                    for (int i = 0; i<arrrss1.count; i++) {
                        
                        shangpingView = [[GoodsView alloc]initWithFrame:CGRectMake(0, 45+(120*i), ScreenWidth, 120)];
                        shangpingView.backgroundColor=[UIColor whiteColor];
                        [shangpingView.headImageFull setImageWithURL:[[arrrss1 objectAtIndex:i] objectForKey:@"imageUrlFull"] placeholderImage:[UIImage imageNamed:@"zhengfangxing"]];
                        [shangpingView.headImageFull.layer setCornerRadius:6.0];
                        [shangpingView.headImageFull.layer setBorderWidth:0.5];
                        [shangpingView.headImageFull.layer setMasksToBounds:YES];
                        CGColorSpaceRef colorSpace2 = CGColorSpaceCreateDeviceRGB();
                        CGColorRef colorref2 = CGColorCreate(colorSpace2,(CGFloat[]){ 0.93, 0.93, 0.93, 0.93 });
                        [shangpingView.headImageFull.layer setBorderColor:colorref2];//边框颜色
                        
                        shangpingView.itemName.text=[NSString stringWithFormat:@"%@ %@",[[arrrss1 objectAtIndex:i] objectForKey:@"itemCode"],[[arrrss1 objectAtIndex:i] objectForKey:@"itemName"]];
                        shangpingView.itemType.text=[NSString stringWithFormat:@"%@",[[arrrss1 objectAtIndex:i] objectForKey:@"specName"]];
                       
                        shangpingView.quantity.text=[NSString stringWithFormat:@"盘点日库存 %@",[[arrrss1 objectAtIndex:i] objectForKey:@"inWhsQuantity"]];
                        
                        NSMutableAttributedString *AttributedStr1 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"盘点日库存 %@",[[arrrss1 objectAtIndex:i] objectForKey:@"inWhsQuantity"]]];
                        
                        [AttributedStr1 addAttribute:NSFontAttributeName
                         
                                               value:[UIFont systemFontOfSize:13]
                         
                                               range:NSMakeRange(0, 5)];
                        
                        [AttributedStr1 addAttribute:NSForegroundColorAttributeName
                         
                                               value:shenhuiColor
                         
                                               range:NSMakeRange(0, 5)];
                        
                        
                        shangpingView.quantity.attributedText = AttributedStr1;
                        
                        shangpingView.dealPrice.text=[NSString stringWithFormat:@"已盘点 %@",[[arrrss1 objectAtIndex:i] objectForKey:@"quantity"]];
                        shangpingView.dealPrice.textColor=hongseColor;
                        shangpingView.dealPrice.font=[UIFont systemFontOfSize:13];
                        NSMutableAttributedString *AttributedStr12 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"已盘点 %@",[[arrrss1 objectAtIndex:i] objectForKey:@"quantity"]]];
                        
                        [AttributedStr12 addAttribute:NSFontAttributeName
                         
                                                value:[UIFont systemFontOfSize:13]
                         
                                                range:NSMakeRange(0, 3)];
                        
                        [AttributedStr12 addAttribute:NSForegroundColorAttributeName
                         
                                                value:shenhuiColor
                         
                                                range:NSMakeRange(0, 3)];
                        
                        
                        shangpingView.dealPrice.attributedText = AttributedStr12;
                        shangpingView.diffQuantity.text=[NSString stringWithFormat:@"盘盈 %@",[[arrrss1 objectAtIndex:i] objectForKey:@"diffQuantity"]];
                        shangpingView.diffQuantity.textColor=hongseColor;
                        shangpingView.diffQuantity.font=[UIFont systemFontOfSize:13];
                        NSMutableAttributedString *AttributedStr112 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"盘盈 %@",[[arrrss1 objectAtIndex:i] objectForKey:@"diffQuantity"]]];
                        
                        [AttributedStr112 addAttribute:NSFontAttributeName
                         
                                                value:[UIFont systemFontOfSize:13]
                         
                                                range:NSMakeRange(0, 3)];
                        
                        [AttributedStr112 addAttribute:NSForegroundColorAttributeName
                         
                                                value:shenhuiColor
                         
                                                range:NSMakeRange(0, 3)];
                        
                        
                        shangpingView.diffQuantity.attributedText = AttributedStr112;
                        if (i==arrrss1.count-1) {
                            UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(0, 120-0.40, ScreenWidth, 0.40)];
                            lineLabel1.backgroundColor=qianhuiColor;
                            [shangpingView addSubview:lineLabel1];
                        }else{
                            UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(10, 120-0.40, ScreenWidth-20, 0.40)];
                            lineLabel1.backgroundColor=qianhuiColor;
                            [shangpingView addSubview:lineLabel1];
                            
                            
                        }
                        
                        [MYmainScroll1 addSubview:shangpingView];
                        
                    }
                    
                    
                   
                    MYmainScroll1.contentSize = CGSizeMake(ScreenWidth, shangpingView.bottom+100);
                }else{
               
                    NoLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, 120, ScreenWidth, 45)];
                    NoLabel.text=@"暂无盘盈商品信息！";
                    NoLabel.textAlignment=NSTextAlignmentCenter;
                    NoLabel.textColor=shenhuiColor;
                    NoLabel.font=[UIFont systemFontOfSize:15];
                    [MYmainScroll1 addSubview:NoLabel];

                
                }
                UIView*shangpingxinxiview=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 45)];
                shangpingxinxiview.backgroundColor=[UIColor whiteColor];
                [MYmainScroll1 addSubview:shangpingxinxiview];
                UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(10, 45-0.40, ScreenWidth-20, 0.40)];
                lineLabel1.backgroundColor=qianhuiColor;
                [shangpingxinxiview addSubview:lineLabel1];
                
                UILabel*shangpingxinxi=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, 80, 45)];
                shangpingxinxi.text=@"商品信息";
                shangpingxinxi.textColor=qianheiColor;
                shangpingxinxi.font=[UIFont systemFontOfSize:15];
                [shangpingxinxiview addSubview:shangpingxinxi];
                UILabel*totalQuantity=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth-250, 0, 230, 45)];
                totalQuantity.textColor = shenhuiColor;
                totalQuantity.textAlignment = NSTextAlignmentRight;
                totalQuantity.text=[NSString stringWithFormat:@"共 %@ 件 盘盈 %@ 件",[severDataDict.dataDict objectForKey:@"InWhsTotal"],[severDataDict.dataDict objectForKey:@"QuantityTotal"]];
                totalQuantity.font = [UIFont systemFontOfSize:13];
                
                [shangpingxinxiview addSubview:totalQuantity];

                
            }else{
                [Global hideProgressHUDInternal:self.view];
                NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                [Global showTextHudSub:requestResultStr view:self.view];
            }
            
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
           [Global showTextHudSub:severDataDict.resultStr view:self.view];
        }
        
    }];
   
    NSMutableDictionary *param3 = [NSMutableDictionary new];
    [param3 setValue:Token forKey:@"tokenId"];
    [param3 setValue:self.orderId forKey:@"ckvId"];
    [param3 setValue:@"loss" forKey:@"ckStatus"];
    [HttpRequest requestData:@"Business/CheckVouch/ItemList" params:param3 success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
          NSLog(@"loss======-----------%@", severDataDict.dataDict);
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [Global hideProgressHUDInternal:self.view];
                arrrss2=[[NSMutableArray alloc]init];
                arrrss2=[severDataDict.dataDict objectForKey:@"DataLine"];
                if (arrrss2.count>0) {
                    
                    for (int i = 0; i<arrrss2.count; i++) {
                        
                        shangpingView = [[GoodsView alloc]initWithFrame:CGRectMake(0, 45+(120*i), ScreenWidth, 120)];
                        shangpingView.backgroundColor=[UIColor whiteColor];
                        [shangpingView.headImageFull setImageWithURL:[[arrrss2 objectAtIndex:i] objectForKey:@"imageUrlFull"] placeholderImage:[UIImage imageNamed:@"zhengfangxing"]];
                        [shangpingView.headImageFull.layer setCornerRadius:6.0];
                        [shangpingView.headImageFull.layer setBorderWidth:0.5];
                        [shangpingView.headImageFull.layer setMasksToBounds:YES];
                        CGColorSpaceRef colorSpace2 = CGColorSpaceCreateDeviceRGB();
                        CGColorRef colorref2 = CGColorCreate(colorSpace2,(CGFloat[]){ 0.93, 0.93, 0.93, 0.93 });
                        [shangpingView.headImageFull.layer setBorderColor:colorref2];//边框颜色
                        
                        shangpingView.itemName.text=[NSString stringWithFormat:@"%@ %@",[[arrrss2 objectAtIndex:i] objectForKey:@"itemCode"],[[arrrss2 objectAtIndex:i] objectForKey:@"itemName"]];
                         shangpingView.itemType.text=[NSString stringWithFormat:@"%@",[[arrrss2 objectAtIndex:i] objectForKey:@"specName"]];
                        shangpingView.quantity.text=[NSString stringWithFormat:@"盘点日库存 %@",[[arrrss2 objectAtIndex:i] objectForKey:@"inWhsQuantity"]];
                        
                        NSMutableAttributedString *AttributedStr1 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"盘点日库存 %@",[[arrrss2 objectAtIndex:i] objectForKey:@"inWhsQuantity"]]];
                        
                        [AttributedStr1 addAttribute:NSFontAttributeName
                         
                                               value:[UIFont systemFontOfSize:13]
                         
                                               range:NSMakeRange(0, 5)];
                        
                        [AttributedStr1 addAttribute:NSForegroundColorAttributeName
                         
                                               value:shenhuiColor
                         
                                               range:NSMakeRange(0, 5)];
                        
                        
                        shangpingView.quantity.attributedText = AttributedStr1;
                        
                        shangpingView.dealPrice.text=[NSString stringWithFormat:@"已盘点 %@",[[arrrss2 objectAtIndex:i] objectForKey:@"quantity"]];
                        shangpingView.dealPrice.textColor=hongseColor;
                        shangpingView.dealPrice.font=[UIFont systemFontOfSize:13];
                        NSMutableAttributedString *AttributedStr12 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"已盘点 %@",[[arrrss2 objectAtIndex:i] objectForKey:@"quantity"]]];
                        
                        [AttributedStr12 addAttribute:NSFontAttributeName
                         
                                                value:[UIFont systemFontOfSize:13]
                         
                                                range:NSMakeRange(0, 3)];
                        
                        [AttributedStr12 addAttribute:NSForegroundColorAttributeName
                         
                                                value:shenhuiColor
                         
                                                range:NSMakeRange(0, 3)];
                        
                        
                        shangpingView.dealPrice.attributedText = AttributedStr12;
                        shangpingView.diffQuantity.text=[NSString stringWithFormat:@"盘亏 %@",[[arrrss2 objectAtIndex:i] objectForKey:@"diffQuantity"]];
                        shangpingView.diffQuantity.textColor=hongseColor;
                        shangpingView.diffQuantity.font=[UIFont systemFontOfSize:13];
                        NSMutableAttributedString *AttributedStr112 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"盘亏 %@",[[arrrss2 objectAtIndex:i] objectForKey:@"diffQuantity"]]];
                        
                        [AttributedStr112 addAttribute:NSFontAttributeName
                         
                                                 value:[UIFont systemFontOfSize:13]
                         
                                                 range:NSMakeRange(0, 3)];
                        
                        [AttributedStr112 addAttribute:NSForegroundColorAttributeName
                         
                                                 value:shenhuiColor
                         
                                                 range:NSMakeRange(0, 3)];
                        
                        
                        shangpingView.diffQuantity.attributedText = AttributedStr112;
                        if (i==arrrss2.count-1) {
                            UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(0, 120-0.40, ScreenWidth, 0.40)];
                            lineLabel1.backgroundColor=qianhuiColor;
                            [shangpingView addSubview:lineLabel1];
                        }else{
                            UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(10, 120-0.40, ScreenWidth-20, 0.40)];
                            lineLabel1.backgroundColor=qianhuiColor;
                            [shangpingView addSubview:lineLabel1];
                            
                            
                        }
                        [MYmainScroll2 addSubview:shangpingView];
                        
                    }
                    
                    MYmainScroll2.contentSize = CGSizeMake(ScreenWidth, shangpingView.bottom+100);
                }else{
                    NoLabel1=[[UILabel alloc]initWithFrame:CGRectMake(0, 120, ScreenWidth, 45)];
                    NoLabel1.text=@"暂无盘亏商品信息！";
                    NoLabel1.textColor=shenhuiColor;
                    NoLabel1.textAlignment=NSTextAlignmentCenter;
                    NoLabel1.font=[UIFont systemFontOfSize:15];
                    [MYmainScroll2 addSubview:NoLabel1];
                
                }
                UIView*shangpingxinxiview=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 45)];
                shangpingxinxiview.backgroundColor=[UIColor whiteColor];
                [MYmainScroll2 addSubview:shangpingxinxiview];
                UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(10, 45-0.40, ScreenWidth-20, 0.40)];
                lineLabel1.backgroundColor=qianhuiColor;
                [shangpingxinxiview addSubview:lineLabel1];
                
                UILabel*shangpingxinxi=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, 80, 45)];
                shangpingxinxi.text=@"商品信息";
                shangpingxinxi.textColor=qianheiColor;
                shangpingxinxi.font=[UIFont systemFontOfSize:15];
                [shangpingxinxiview addSubview:shangpingxinxi];
                UILabel*totalQuantity=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth-250, 0, 230, 45)];
                totalQuantity.textColor = shenhuiColor;
                totalQuantity.textAlignment = NSTextAlignmentRight;
                totalQuantity.text=[NSString stringWithFormat:@"共 %@ 件 盘亏 %@ 件",[severDataDict.dataDict objectForKey:@"InWhsTotal"],[severDataDict.dataDict objectForKey:@"QuantityTotal"]];
                totalQuantity.font = [UIFont systemFontOfSize:13];
                [shangpingxinxiview addSubview:totalQuantity];

            }else{
                [Global hideProgressHUDInternal:self.view];
                NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                [Global showTextHudSub:requestResultStr view:self.view];
            }
            }
        else
        {
            [Global hideProgressHUDInternal:self.view];
            [Global showTextHudSub:severDataDict.resultStr view:self.view];
        }
        
    }];

}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{       if (self.scrollView.bounds.origin.x==0) {
        self.moveImage.frame = CGRectMake(0, 50, ScreenWidth/3, 1.5);
        [bu setTitleColor:backColor forState:UIControlStateNormal];
        [bu1 setTitleColor:shenhuiColor forState:UIControlStateNormal];
        [bu2 setTitleColor:shenhuiColor forState:UIControlStateNormal];
    }
    
    if (self.scrollView.bounds.origin.x==ScreenWidth) {
        self.moveImage.frame = CGRectMake(ScreenWidth/3, 50, ScreenWidth/3, 1.5);
        [bu1 setTitleColor:backColor forState:UIControlStateNormal];
        [bu setTitleColor:shenhuiColor forState:UIControlStateNormal];
        [bu2 setTitleColor:shenhuiColor forState:UIControlStateNormal];
       }
    
    if (self.scrollView.bounds.origin.x==ScreenWidth*2) {
        self.moveImage.frame = CGRectMake(ScreenWidth/3*2, 50, ScreenWidth/3, 1.5);
        [bu1 setTitleColor:shenhuiColor forState:UIControlStateNormal];
        [bu setTitleColor:shenhuiColor forState:UIControlStateNormal];
        [bu2 setTitleColor:backColor forState:UIControlStateNormal];
       
    }
}
-(void)queren:(UIButton*)sender{
    
    UIAlertView* alts = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"是否确认盘点？" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认", nil];
    [alts show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    
    if (buttonIndex == 1) {
        NSMutableDictionary *param3 = [NSMutableDictionary new];
        [param3 setValue:Token forKey:@"tokenId"];
        [param3 setValue:self.orderId forKey:@"ckvId"];
    [HttpRequest requestData:@"Business/CheckVouch/Confirm" params:param3 success:^(BOOL isSuccess, SeverData *severDataDict) {
            if (isSuccess) {
//                NSLog(@"======-----------%@", severDataDict.dataDict);
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                    [Global hideProgressHUDInternal:self.view];
                    [self showAlertMessage:@"盘点确认成功"];
                        [tureBtn removeFromSuperview];
                        [self jiazaishuju];
                        [_delegate upster:@""];
                        [isActive setTextColor:luseColor];
                        isActive.text=@"已确认";
                        [operationsBtn removeFromSuperview];
                        operationsBtn = [[UIButton alloc] initWithFrame:CGRectMake(30, 0.0,  60/2, 60/2)];
                        [operationsBtn setTitle:@"   " forState:UIControlStateNormal];
                        [operationsBtn setTitleColor:luseColor forState:UIControlStateNormal];
                        operationsBtn.titleLabel.font=[UIFont systemFontOfSize:28];
                        UIBarButtonItem* myBtnBtn = [[UIBarButtonItem alloc] initWithCustomView:operationsBtn];
                        self.navigationItem.rightBarButtonItem = myBtnBtn;
                        [_delegate secondViewController:self upster:@""];
                    
                    
                }else{
                    [Global hideProgressHUDInternal:self.view];
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    [Global showTextHudSub:requestResultStr view:self.view];
                }
            }
            else
            {
                [Global hideProgressHUDInternal:self.view];
               [Global showTextHudSub:severDataDict.resultStr view:self.view];
            }
            
        }];}
}
-(void)addd{
    MYmainScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0,0, ScreenWidth, ScreenHeight-220)];
    [MYmainScroll setBackgroundColor: zuiqianhuiColor];
    MYmainScroll.delegate = self;
    MYmainScroll.userInteractionEnabled = YES;
    MYmainScroll.scrollEnabled = YES;
    MYmainScroll.showsVerticalScrollIndicator = FALSE;
    MYmainScroll.showsHorizontalScrollIndicator = FALSE;
    
    MYmainScroll1 = [[UIScrollView alloc] initWithFrame:CGRectMake(ScreenWidth,0, ScreenWidth, ScreenHeight-220)];
    [MYmainScroll1 setBackgroundColor: zuiqianhuiColor];
    MYmainScroll1.delegate = self;
    MYmainScroll1.userInteractionEnabled = YES;
    MYmainScroll1.scrollEnabled = YES;
    MYmainScroll1.showsVerticalScrollIndicator = FALSE;
    MYmainScroll1.showsHorizontalScrollIndicator = FALSE;
    
    MYmainScroll2 = [[UIScrollView alloc] initWithFrame:CGRectMake(ScreenWidth*2,0, ScreenWidth, ScreenHeight-220)];
    [MYmainScroll2 setBackgroundColor: zuiqianhuiColor];
    MYmainScroll2.delegate = self;
    MYmainScroll2.userInteractionEnabled = YES;
    MYmainScroll2.scrollEnabled = YES;
    MYmainScroll2.showsVerticalScrollIndicator = FALSE;
    MYmainScroll2.showsHorizontalScrollIndicator = FALSE;
    
    self.scrollView = [[UIScrollView alloc] init];
    self.scrollView.frame = CGRectMake(0, view2.bottom+50+10, ScreenWidth, ScreenHeight-220);
    self.scrollView.pagingEnabled = YES;
    self.scrollView.showsHorizontalScrollIndicator = NO;
    self.scrollView.showsVerticalScrollIndicator = NO;
    [self.view addSubview:self.scrollView];
    NSArray * ads = @[@"",@"",@""];
    for (int h = 0 ; h < ads.count; h++) {
        UIImage * image = [UIImage imageNamed:ads[h]];
        UIImageView * imageView = [[UIImageView alloc] initWithImage:image];
        CGRect frame = self.scrollView.frame;
        frame.origin.x = h * frame.size.width;
        frame.origin.y = 0;
        imageView.frame = frame;
        
        [self.scrollView addSubview:imageView];
        }
    
    CGSize size = self.scrollView.frame.size;
    size.width *= 3;
    self.scrollView.contentSize = size;
    self.scrollView.delegate = self;
    [self.scrollView addSubview:MYmainScroll];
    [self.scrollView addSubview:MYmainScroll1];
    [self.scrollView addSubview:MYmainScroll2];
    [self jiazai];
    
    if ([[self.Dict objectForKey:@"ckvStatus"]isEqualToString:@"YP"]) {
        tureBtn=[[UIButton alloc]initWithFrame:CGRectMake(0, ScreenHeight-48, ScreenWidth, 48)];
        [tureBtn setTitle:@"盘点确认" forState:UIControlStateNormal];
        tureBtn.backgroundColor=luseColor;
        [tureBtn addTarget:self action:@selector(queren:) forControlEvents:UIControlEventTouchUpInside];
        [tureBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [self.view addSubview:tureBtn];
        
    }else{
        }

    self.customTabBar = [[UIView alloc]initWithFrame:CGRectMake(0,view2.bottom+10, ScreenWidth, 50)];
    self.customTabBar .backgroundColor=[UIColor whiteColor];
    [self.view addSubview:self.customTabBar];
    
    UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 0.45)];
    lineLabel1.backgroundColor=qianhuiColor;
    [self.customTabBar addSubview:lineLabel1];

    UILabel *lineLabe2=[[UILabel alloc] initWithFrame:CGRectMake(0, 50-0.40, ScreenWidth, 0.45)];
    lineLabe2.backgroundColor=qianhuiColor;
    [self.customTabBar addSubview:lineLabe2];
    //添加移动的图片
    bu=[[UIButton alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth/3, 50)];
    [bu setTitle:[NSString stringWithFormat:@"盘存%@件",  [self.Dict objectForKey:@"balance"]]   forState:UIControlStateNormal];
    [bu setTitleColor:qianheiColor forState:UIControlStateNormal];
    bu .titleLabel.font=[UIFont systemFontOfSize:15];
    [bu addTarget:self action:@selector(tabBarItemClicked) forControlEvents:UIControlEventTouchUpInside];
    [self.customTabBar addSubview:bu];
    
    bu1=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth/3, 0, ScreenWidth/3, 50)];
    [bu1 setTitle:[NSString stringWithFormat:@"盘盈%@件",  [self.Dict objectForKey:@"gain"]]   forState:UIControlStateNormal];
    [bu1 setTitleColor:zhonghuiColor forState:UIControlStateNormal];
    bu1 .titleLabel.font=[UIFont systemFontOfSize:15];
    [bu1 addTarget:self action:@selector(tabBarItemClicked1) forControlEvents:UIControlEventTouchUpInside];
    [self.customTabBar addSubview:bu1];
    
    bu2=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth/3*2, 0, ScreenWidth/3,50)];
    [bu2 setTitle:[NSString stringWithFormat:@"盘亏%@件",  [self.Dict objectForKey:@"loss"]]   forState:UIControlStateNormal];
    [bu2 setTitleColor:zhonghuiColor forState:UIControlStateNormal];
    bu2 .titleLabel.font=[UIFont systemFontOfSize:15];
    [bu2 addTarget:self action:@selector(tabBarItemClicked2) forControlEvents:UIControlEventTouchUpInside];
    [self.customTabBar addSubview:bu2];
    
    self.moveImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"tabbar_slider.png"]];
    self.moveImage.backgroundColor=luseColor;
    self.moveImage.frame = CGRectMake(0, 0, ScreenWidth/3, 1.5);
    CGFloat sliderImageViewCenterX = ScreenWidth/3/2;
    [self.moveImage setCenter:CGPointMake(sliderImageViewCenterX, 51)];
    [self.customTabBar addSubview:_moveImage];
}

-(void)tabBarItemClicked{
    //更换moveImage的位置
    [bu1 setTitleColor:zhonghuiColor forState:UIControlStateNormal];
    [bu setTitleColor:qianheiColor forState:UIControlStateNormal];
    [bu2 setTitleColor:zhonghuiColor forState:UIControlStateNormal];
    CGFloat sliderImageViewCenterX = ScreenWidth/3/2 + (0 * ScreenWidth/3);
    [UIView animateWithDuration:0.2f animations:^{
        self.moveImage.center = CGPointMake(sliderImageViewCenterX, self.moveImage.center.y);
        
}];
    
    [self.scrollView setContentOffset:CGPointMake(0, 0) ];
    self.scrollView.bouncesZoom=NO;
}
-(void)tabBarItemClicked1{
    //更换moveImage的位置
    [bu1 setTitleColor:qianheiColor forState:UIControlStateNormal];
    [bu setTitleColor:zhonghuiColor forState:UIControlStateNormal];
    [bu2 setTitleColor:zhonghuiColor forState:UIControlStateNormal];
    
    CGFloat sliderImageViewCenterX = ScreenWidth/3/2 + (1 * ScreenWidth/3);
    [UIView animateWithDuration:0.2f animations:^{
        self.moveImage.center = CGPointMake(sliderImageViewCenterX, self.moveImage.center.y);
        }];
    
    [self.scrollView setContentOffset:CGPointMake(ScreenWidth, 0) ];
    self.scrollView.bouncesZoom=NO;
}
-(void)tabBarItemClicked2{
    //更换moveImage的位置
    [bu1 setTitleColor:zhonghuiColor forState:UIControlStateNormal];
    [bu setTitleColor:zhonghuiColor forState:UIControlStateNormal];
    [bu2 setTitleColor:qianheiColor forState:UIControlStateNormal];
    
    CGFloat sliderImageViewCenterX = ScreenWidth/3/2 + (2 * ScreenWidth/3);
    [UIView animateWithDuration:0.2f animations:^{
        self.moveImage.center = CGPointMake(sliderImageViewCenterX, self.moveImage.center.y);
        
}];
    
    [self.scrollView setContentOffset:CGPointMake(ScreenWidth*2, 0) ];
    self.scrollView.bouncesZoom=NO;
}
- (void)showAlertWait
{
    alt = [[UIAlertView alloc] initWithTitle:@"网络不稳定 ！" message:@"请确认网络" delegate:self cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:1.0f];
    
}
- (void)showAlertMessage:(NSString *)msg
{
    alt = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:msg delegate:nil cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:1.0f];
}
- (void)hideAlert
{
    if (alt != nil)
    {
        [alt dismissWithClickedButtonIndex:0 animated:YES];
        alt = nil;
    }
}
@end
